list
Represents a mutable array list. Subtype of collection<T>
.
Since
0.6.0
See also
for inherited values and methods
Constructors
Functions
Append an element to the end of this collection.
The element is not added if this collection does not allow duplicates and the element is already contained in this collection.
Insert a value at the specified index. Any elements previously occurring at and after the specified index have their indices increased by 1, and the size of the list increases by 1.
Note that for a list my_list
:
my_list.add(my_list.size(), x)
"appends"x
to the end of the listmy_list.add(my_list.size() + 1, x)
throws an exception
Note also that my_list.add(my_list.size(), x)
is equivalent to my_list.add(x)
(inherited from collection<T>
).
Add all elements from another collection to the end of this collection.
If this collection does not allow duplicates, then only those elements not already contained in this collection are added.
Insert all elements from a collection at the specified index. Any elements previously occurring at and after the specified index have their indices increased by the size of the given collection. The size of the list increases by the size of the given collection.
Note that for a list my_list
:
my_list.add_all(my_list.size(), x)
"appends" the elements of the collectionx
to the end of the listmy_list.add_all(my_list.size() + 1, x)
throws an exception
Note also that my_list.add_all(my_list.size(), x)
is equivalent to my_list.add_all(x)
(inherited from collection<T>
).
Add all elements from another collection to the end of this collection.
If this collection does not allow duplicates, then only those elements not already contained in this collection are added.
Insert all elements from a collection at the specified index. Any elements previously occurring at and after the specified index have their indices increased by the size of the given collection. The size of the list increases by the size of the given collection.
Note that for a list my_list
:
my_list.add_all(my_list.size(), x)
"appends" the elements of the collectionx
to the end of the listmy_list.add_all(my_list.size() + 1, x)
throws an exception
Note also that my_list.add_all(my_list.size(), x)
is equivalent to my_list.add_all(x)
(inherited from collection<T>
).
Check if this collection contains all elements of another collection.
Check if this collection contains all elements of another collection.
Generate a textual representation of this iterable.
An optional separator, prefix and postfix can be provided. One can also provide a limit: integer?
. If there are more elements in the result than limit
, the elements whose indices exceed limit
are omitted, and the passed truncated: text
is included instead.
Examples:
[1, 2, 3].join_to_text()
returns'1, 2, 3'
.[1, 2, 3].join_to_text('_')
returns'1_2_3'
.[1, 2, 3].join_to_text('*', '(', ')')
returns'(1*2*3)'
.list<T>().join_to_text('!', '(', ')')
returns'()'
(whereT
is a valid type).range(10).join_to_text('', '', '', 5)
returns'01234...'
.range(10).join_to_text('', '', '', 5, 'more')
returns'01234more'
.
Where the function even
is defined:
function even(x: integer): text {
return if (x % 2 == 0) 'EVEN' else 'ODD';
}
Then:
range(10).join_to_text('->', '{', '}', 5, '...', even(*))
returns{EVEN->ODD->EVEN->ODD->EVEN->...}
.
Remove all elements in another collection from this collection.
Remove all elements in another collection from this collection.
Returns a sublist of this list starting from the specified index (inclusive).
Equivalent to list.sub(index, list.size())
.
Note that:
my_list.sub(my_list.size() - 1)
returns a list containing only the last element ofmy_list
(assumingmy_list.size > 0
)my_list.sub(my_list.size())
returns an empty listmy_list.sub(my_list.size() + 1)
throws an exception
Returns a sublist of this list starting from the specified start index (inclusive) to the specified end index (exclusive).
For the list my_list
, my_list.sub(start, my_list.size())
is equivalent to my_list.sub(start)
.